#ifndef __SIMPLE__PARTICLE__RENDER__H__
#define __SIMPLE__PARTICLE__RENDER__H__
#include "IRender.h"
#include <string>
#define NUM_PARTICLES 800
class SimpleParticleRender : public IRender
{
protected:
	struct ParticleItem
	{
		float birthPosition[3];
		float initV[3];
		float initSpeed;
		float birthTime;
		float deathTime;
	};
public:
	SimpleParticleRender(const std::string& name);
	virtual ~SimpleParticleRender();
	virtual void idle() override;
	virtual void draw() override;

protected:
	void createParticle();
	void initParticleItem(ParticleItem* particle);
	void checkParticleDeath();

private:
	PROGRAM_HANDLE mHandle;
	PROGRAM_HANDLE mHandleFragment;
	ParticleItem mFixed[NUM_PARTICLES];
	ParticleItem* mPools[NUM_PARTICLES];
	int mPooled;
	ParticleItem* mAlives[NUM_PARTICLES];
	int mAlived;
	float mTime;
	float mIntervalTime;

	CGprogram mVertexProgram;
	CGparameter mvp;
};
#endif//__SIMPLE__PARTICLE__RENDER__H__